package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"wakitsoft.com/resume/config"
	"wakitsoft.com/resume/controllers"
	"wakitsoft.com/resume/db"
	"wakitsoft.com/resume/libs"
)

func main() {
	config.Init()
	if err := db.InitDB(config.Instance()); err != nil {
		panic(err)
	}
	app := gin.Default()
	app.Use(libs.Cors(config.Instance().App.Web.Cors))
	app.Static("/uploads", "./uploads")
	app.POST("/resumes", controllers.CreateResume)
	app.PUT("/resumes/:id", controllers.UpdateResume)
	app.GET("/resumes", controllers.GetResumes)
	app.GET("/resumes/:id", controllers.GetResume)
	app.DELETE("/resumes/:id", controllers.DeleteResume)
	app.POST("/image", controllers.UploadImage)

	app.POST("/tech-stacks", controllers.CreateTechStack)
	app.GET("/tech-stacks", controllers.GetTechStacks)
	app.PUT("/tech-stacks/:id", controllers.UpdateTechStack)
	app.DELETE("/tech-stacks/:id", controllers.DeleteTechStack)

	app.POST("/schools", controllers.CreateSchool)
	app.GET("/schools", controllers.GetSchools)
	app.GET("/schools/:id", controllers.GetSchool)
	app.PUT("/schools/:id", controllers.UpdateSchool)
	app.DELETE("/schools/:id", controllers.DeleteSchool)
	app.POST("/pdf", controllers.CreatePdf)
	port := config.Instance().App.Web.Port
	if err := app.Run(fmt.Sprintf(":%d", port)); err != nil {
		panic(err)
	}

}
